package com.snda.relation.service.activities.biz;

import com.snda.relation.service.opensocial.UpdateResponse;
import com.snda.commons.servicegate.annotations.Endpoint;
import com.snda.commons.servicegate.annotations.Param;
import com.snda.commons.servicegate.annotations.Service;
import com.snda.commons.servicegate.validation.Text;
import com.snda.commons.servicegate.validation.Number;

/**
 * 2010-2020 Company: www.sdo.com
 * 
 * @author: lijian
 * @version: 1.0
 */
@Service("ActivityService")
public interface IActivityService {

	/**
	 * add activity
	 * 
	 * @param param
	 *            xml or json format string
	 * @param format
	 *            xml or json
	 * @param appId
	 * @param accountType
	 *            account type 0 digital account. 1 PT account
	 */
	@Endpoint
	public UpdateResponse addActivity(
			@Param("param") @Text(maxLength = 5000) String param,
			@Param("format") String format, @Param("appId") @Number(min =1) long appId,
			@Param(value = "accountType", optional = true,  defaultValue = "0") int accountType)
			throws Exception;

	/**
	 * upload templatized activity
	 * 
	 * @param param
	 *            xml or json format String
	 * @param format
	 *            'xml' or 'json'
	 * @param appId
	 */

	@Endpoint
	public UpdateResponse addTemplatizedActivity(@Param("sdid") @Number(min =1) long sdid,
			@Param("titleData") @Text(maxLength = 3000) String titleData,
			@Param("bodyData") @Text(maxLength = 2000) String bodyData,
			@Param("templateId") @Number(min =1) long templateId, @Param("appId") @Number(min =1) long appId,
			@Param("createTime") long createTime, @Param(value = "extendData", optional=true, defaultValue="") String extendData) throws Exception;

	/**
	 * Get friend feeds;
	 * 
	 * @param sdid
	 * @param timestamp
	 *            yyyy-MM-dd HH:mm:ss
	 * @param isPrevious
	 *            true, get activities which is created before timestamp; else
	 *            false
	 * @param range
	 *            1 self feed; 2 friends feed; 3 self and friend feed
	 * @return
	 * @throws Exception
	 */
	@Endpoint(alias = "getFeeds", raw = true)
	public String getFeeds(
			@Param("sdid") @Number(min =1) long sdid,
			@Param(value = "timestamp", optional = true, defaultValue = "0") long timestamp,
			@Param(value = "activityTypes", optional = true) long[] activityTypes,
			@Param(value = "excludedTypes", optional = true) long[] excludedTypes,
			@Param(value = "acceptedApps", optional = true) long[] acceptedApps,
			@Param(value = "excludedApps", optional = true) long[] excludedApps,
			@Param(value = "isPrevious", optional = true, defaultValue = "true") boolean isPrevious,
			@Param(value = "count", optional = true, defaultValue = "30") @Number(max = 300, min = 1) int count,
			@Param(value = "range", optional = true, defaultValue = "3") int range)
			throws Exception;
	
	/**
	 * Get self logEvents;
	 * 
	 * @param sdid
	 * @param timestamp
	 * @param isPrevious
	 *            true, get activities which is created before timestamp; else
	 *            false
	 * @return
	 * @throws Exception
	 */
	@Endpoint(alias="getUserEvents", raw = true)
	public String getUserEvents(@Param("sdids") long[] sdids,
			@Param(value = "activityTypes", optional = true) long[] activityTypes,
			@Param(value = "excludedTypes", optional = true) long[] excludedTypes,
			@Param(value = "acceptedApps", optional = true) long[] acceptedApps,
			@Param(value = "excludedApps", optional = true) long[] excludedApps,
			@Param(value = "timestamp", optional = true, defaultValue = "0") long timestamp,
			@Param(value = "isPrevious", optional = true, defaultValue = "true") boolean isPrevious,
			@Param(value = "count", optional = true, defaultValue = "30") @Number(max=300, min = 1) int count
			)throws Exception;
	
	/**
	 * delete activity by sdid and id(DB primary key)
	 * 
	 * @param sdid
	 * @param id
	 *            DB primary key
	 * @param cascade
	 *            true delete original activity and all pushed activities; false
	 *            only delete original activity
	 * @return
	 * @throws Exception
	 */
	@Endpoint(alias="deleteFeeds")
	public UpdateResponse deleteFeeds(@Param("sdid") @Number(min =1) long sdid,
			@Param("uuid") String[] uuid, @Param(value = "cascade", optional = true, defaultValue="false") boolean cascade)
			throws Exception;
}
